<template>
    <div class="detailBox">
        <h1 class="title">{{ newsInfo.title }}</h1>
        <p class="subtitle">
            <span>发表时间: {{newsInfo.add_time}}</span>
            <span>点击次数: {{newsInfo.click}}次</span>
        </p>
        <hr>
        <div class="content" v-html="newsInfo.content">
            
        </div>
    </div>
    
</template>
<script>
    import {Toast} from "mint-ui";
    export default {
        data(){
            return {
                id: this.$route.params.id,
                newsInfo: {}  //新闻对象
            }
        },
        created() {
            this. getNewsDetail();
        },
        methods: {
            getNewsDetail(){
                this.$http.get('api/getnew/'+this.id).then(result => {
                    if(result.body.status == 0) {
                        // console.log(result.body);
                        this.newsInfo = result.body.message[0];
                    }else {
                        Toast('获取详情失败');
                    }
                })
            }
        }
    }
</script>
<style lang="scss">
    .detailBox {
        padding: 0 4px;
        .title {
            text-align: center;
            margin: 15px 0;
            font-size: 16px;
            color: red;
        }
        .subtitle {
            color: #226aff;
            display: flex;
            justify-content: space-between;
            font-size: 13px;
        }
        .content {
            img {
                width: 100%;
            }
        }
    }
</style>
